from IPython.display import display
from bokeh.plotting import output_notebook
output_notebook()
# Set a location name
location = "Roanne"
%%time
from osmrx import Pois
pois_object = Pois()
pois_object.from_location(location)
# Get the roads data: a list of dict containing the geometry and the attributes
pois_data = pois_object.data
2023-04-06 22:37:48 - Pois - INFO : Building OsmFeatureModes.poi Data 2023-04-06 22:37:48 - Pois - INFO : Building the query 2023-04-06 22:37:50 - Pois - INFO : NominatimApi: Query 200:OK in 2.01 sec. 2023-04-06 22:37:51 - Pois - INFO : From Roanne 2023-04-06 22:37:51 - Pois - INFO : Building the query 2023-04-06 22:37:51 - Pois - INFO : Execute the query 2023-04-06 22:37:52 - Pois - INFO : OverpassApi: Query 200:OK in 0.93 sec. CPU times: user 525 ms, sys: 117 ms, total: 642 ms Wall time: 3.52 s
%%time
from osmrx import Roads
# Let's to get the roads network and connect POIs found on the same location
vehicle_object = Roads("vehicle",
pois_object.data)
vehicle_object.from_location(location)
# Get the roads data: a list of dict containing the geometry and the attributes
roads_data = vehicle_object.data
2023-04-06 22:37:52 - Roads - INFO : Building OsmFeatureModes.vehicle Data 2023-04-06 22:37:52 - Roads - INFO : Building the query 2023-04-06 22:37:54 - Roads - INFO : NominatimApi: Query 200:OK in 2.05 sec. 2023-04-06 22:37:54 - Roads - INFO : From Roanne 2023-04-06 22:37:54 - Roads - INFO : Building the query 2023-04-06 22:37:54 - Roads - INFO : Execute the query 2023-04-06 22:37:55 - Roads - INFO : OverpassApi: Query 200:OK in 0.96 sec. 2023-04-06 22:37:56 - Roads - INFO : Network cleaning... 2023-04-06 22:37:56 - Roads - INFO : Starting: Adding new nodes on the network 2023-04-06 22:37:56 - Roads - INFO : Find nearest line for each node 2023-04-06 22:37:56 - Roads - INFO : Split line 2023-04-06 22:37:56 - Roads - INFO : Starting: Find intersections 2023-04-06 22:37:56 - Roads - INFO : Done: Find intersections 2023-04-06 22:37:56 - Roads - INFO : Build lines 2023-04-06 22:37:58 - Roads - INFO : Graph built CPU times: user 2.97 s, sys: 83.9 ms, total: 3.05 s Wall time: 6.54 s
%%time
from bokeh.plotting import show
import geopandas as gpd
from gdf2bokeh import Gdf2Bokeh
map_session = Gdf2Bokeh(
"My network map",
width=800,
height=600,
background_map_name="CARTODBPOSITRON"
)
map_session.add_layer_from_dict_list("Roads", roads_data, from_epsg=4326,
color="black")
map_session.add_layer_from_dict_list("POIs", pois_data, from_epsg=4326,
color="blue", size=9)
map_session.add_layers_on_maps()
show(map_session.figure)